Placing a Calculated Value on a Form

Description

This example shows how to place a calculated value on a form. The example is based on the invoice_items table of the AlphaSports sample database.

Alpha Anywhere documentation and software has traditionally referred to the values that you calculate and place on a layout as "calculated fields". However, these values are not fields, because they are not stored in a table record. They are temporary variables that are created and calculated on demand. If you want to calculate a value for a table field, refer to Calculated Fields.
  1. Display the Forms tab of the Control Panel.

  2. Click New, select the invoice_items table, and click Next >.

  3. Select Custom Form and Next >.

  4. Select "Price" in the Available Fields list and click '>'.

  5. Select "Quantity" in the Available Fields list and click '>'.

  6. Click Next > and Finish. The Form Editor will now display a form that looks something like this:

    images/UG_Calculated_Field2.gif
  7. Select and drag the "" entry from the Drag Drop list onto the form. This will display the New Calculated Field dialog.

  8. Enter "Total" into the Name control.

  9. Click the 'xy' icon in the Expression control to display the Expression Builder.

  10. Double click Field Name in the upper left corner of the dialog. Select "Price" and click Insert.

  11. Place a multiplication symbol after "Price", so the expression is "Price*".

  12. Double click Field Name in the upper left corner of the dialog. Select "Quantity" and click Insert, so the expression is "Price*Quantity".

  13. Click OK to return to the New Calculated Field dialog.

  14. Click OK to return to the Form Editor.

  15. Click to switch to form view.

  16. Enter a value into the Price field, then the Quantity field. Alpha Anywhere will calculate the value of the Total field.

    images/UG_Calculated_Field2b.gif

The labels and controls clearly need formatting. For more information, see Setting Field Properties.

See Also